<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    {tpl style}
    <link rel="stylesheet" type="text/css" href="{$skin}css/js.css" />
    <script type="text/javascript" src="{$skin}js/vue.min.js"></script>
    <title>{$webname}</title>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid" style="position:relative;">
        <div class="navbar-header">
            <a href="javascript:void(0);" class="navbar-brand" onclick="history.back();"><span class="glyphicon glyphicon-chevron-left icon"></span></a>
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#list_nav">
                <span class="glyphicon glyphicon-option-horizontal"></span>
            </button>
        </div>
       <div class="collapse navbar-collapse" id="list_nav">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="{:url('game/rule')}">游戏规则</a></li>
                <li><a href="{:url("game/record/id/$id")}">投注记录</a></li>
                <li><a href="{:url("game/total/id/$id")}">盈利统计</a></li>
                
            </ul>
        </div>
        <p style="position:absolute; top:15px; left:50%; margin-left:-18px; font-size:16px;  text-shadow:2px 2px 3px #ccc;">{$game_name}</p>
    </div>
        <div class="collapse navbar-collapse" id="list_nav">
            <ul class="nav navbar-nav navbar-right" style="display: none">
                <li class="active"><a href="auto.shtml">自定义投注模式</a></li>
                <li><a href="../member_mybank.shtml">小金库</a></li>
                <li><a href="trend.shtml">{$game_name}走势图</a></li>
            </ul>
        </div>
        <p style="position:absolute; top:15px; left:50%; margin-left:-18px; font-size:16px;  text-shadow:2px 2px 3px #ccc;">{$game_name}</p>
    </div>

</nav>
<div id="main" style="margin-top: 60px;">

    <div class="container-fluid" style="display:none">
        <div class="row white_bg js_pad">
            <div class="btn-group text-center" style="width: 95%;">
                <a href="{:url("game/record/id/$id")}" class="btn btn-default btn_pad">我的投注</a>
                <a href="../member_relief.shtml" class="btn btn-default btn_pad">领取救济</a>
                <a href="auto.shtml" class="btn btn-default btn_pad">自动投注</a>
                <a href="rule.shtml" class="btn btn-default btn_pad">游戏规则</a>
            </div>
        </div>
    </div>
    <div class="container-fluid">
        <div class="row">
            <div class="list-group white_bg" id="list">
                <template v-for="v in list">
                    <a href="javascript:;" id="{{v.id}}" class="list-group-item">
                        <div class="container-fluid">
                          <div class="row list_pad">
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left pad0"><span>{{v.id}}</span></div>
                                <template v-if="v.kj==0">
                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-left pad0"><span>{{v.kgtime}}</span></div>
                                </template>
                                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-4 text-left pad0"><span v-if="v.kj==1"><img src="{$skin}img/jg/number_{{v.num0}}.gif" alt="" lass="img-responsive"><img src="{$skin}img/jg/number_{{v.num1}}.gif" alt="" lass="img-responsive"><span v-if="v.num2>=0"><img src="{$skin}img/jg/number_{{v.num2}}.gif" alt="" lass="img-responsive"></span><img src="{$skin}img/jg/number_{{type}}{{v.num}}.gif" alt="" lass="img-responsive"></span>
                                    <template v-if="v.kj==0">
                                        <span v-if="v.stoptime>0">截止<span class="red">{{v.stoptime}}</span>秒</span>
                                        <span v-else>
                                            <span v-if="v.kjtime>0">还有<span class="red">{{v.kjtime}}</span>秒,开奖 </span>
                                                <span v-else>开奖中,请稍后!</span>
                                    </template>
                                </div>
                               
                              
									
									              <div class="col-lg-3 col-md-3 col-sm-3 col-xs-2 pad0 press">
                                    <span v-if="v.status==1"><button class="btn btn-default kj">{{v.points}}/{{v.hdpoints}}</button></span>
                                    <span v-if="v.status==2" id="press"><button class="btn btn-info kj">
                                            <span v-if="v.points>0">已</span>投　注</button></span>
                                    <span v-if="v.status==3"><button class="btn btn-warning kj">开奖中</button></span>
                                </div>
                            </div>
                        </div>
                    </a>
                </template>

            </div>
            <div class="small-show">
                <p><a class="btn btn-danger btn-block" id="clickIn"><span id="clickhtml">点击下注</span> <span class="glyphicon glyphicon-menu-down" id="down" style="display: none;"></span> <span class="glyphicon glyphicon-menu-up" id="up"></span></a></p>


                <div class="row small-btn small-36" id="press">
                    {loop $press $k $v}
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 pad4 item" id="tbNum{$k}">
                        <div class="input-group input-group-lg mb10">
                            <span class="input-group-addon"><img src="{$skin}/img/jg/number_{$in}<?php echo $k+$step;?>.png" width="24px" height="24px" ></span>
                            <input type="number" name="inNum{$k}" id="inNum{$k}" class="form-control"  value=""/>
                            <span class="input-group-addon"><?php echo $odds[$k];?></span>
                        </div>
                    </div>
                    {/loop}


                </div>

            </div>
        </div>
    </div>

</div>
<script type="text/javascript">
    var vm = new Vue({
        el: '#list',
        data: {
            list:[],
            type:'',
            name: 'Vue.js'
        }
    });
    var timerid;
    function getContent(){
        var url="{:url("game/ajax/id/$id")}&t=" + Math.random();
        $.ajax({
            type: "GET",
            url: url,
            dataType: "json",
            timeout:1000,
            success: function(data){
                //alert("xx")
                if(!data.points)data.points=0;
                if(!data.bank)data.bank=0;
                $("#money").text(data.points);
                $("#bank").text(data.bank);
                vm.$data.list=data.list;
                vm.$data.type=data.type;
                timerid=setInterval(djs,1000);
            },
            error:function(jqXHR, textStatus, errorThrown){

                if(textStatus=="timeout"){
                    alert("加载超时，请重试");
                }else{
                    alert(textStatus);
                }
                getContent();
            }
        })
        //alert("test")
    }
    function djs() {
        for(var i in vm.$data.list){
            --vm.$data.list[i].stoptime;
            --vm.$data.list[i].kjtime;
            if(vm.$data.list[i].kj==0 && vm.$data.list[i].kjtime<1){
                console.info('<<'+vm.$data.list[i].kjtime);
                clearInterval(timerid);
                getContent();
                break;
            }
        }
    }
    $(document).ready(function(){
        clearInterval(timerid);
        getContent();
    });
        $(function () {
        $("#list").on('click','.press',function () {
            if($(this).find(".btn").hasClass("btn-default")){
                alert("已过期");
                return false;
            }
            $("#list .btn-danger").removeClass("btn-danger");
            $(this).find('.btn').addClass('btn-danger');
            no=$(this).parents("a").attr("id");
            //location.href="{:url("game/press/id/$id")}&no="+no;

            $("#no").text(no);
            return false;
        });
        $("#list").on("click",".text-left",function () {
            no=$(this).attr("id");
            //location.href="{:url("game/item/id/$id")}&no="+no;
            location.href="{:url("game/record/id/$id")}";
        })
        var flag = 1;
        $('#clickIn').click(function(){
            if(flag == 1){
                $('#list').css('display','none').fadeOut('slow');
                $('#down').css('display','inline-block');
                $('#up').css('display','none');
                $('#clickhtml').html('开奖结果');
                flag = 2;
            }else if(flag == 2){
                $('#list').css('display','block').fadeIn('slow');
                $('#down').css('display','none');
                $('#up').css('display','inline-block');
                $('#clickhtml').html('点击下注');
                flag = 1;
            }
        })
    })

</script>
<nav class="navbar-default navbar-fixed-bottom">
    <div class="container-fluid betting_bottom">
        <div class="row">
            <ul class="nav navbar-nav">
                <div class="row nav_dl">
                    <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 pad0">
                        <a href="javascript:chouma(1);"><img src="{$skin}img/chips_1000.png" class="img-responsive" alt="1"></a>
                        <a href="javascript:chouma(10);"><img src="{$skin}img/chips_10000.png" class="img-responsive" alt="10"></a>
                        <a href="javascript:chouma(100);"><img src="{$skin}img/chips_100000.png" class="img-responsive" alt="100"></a>
                        <a href="javascript:chouma(500);"><img src="{$skin}img/chips_500000.png" class="img-responsive" alt="500"></a>
                        <a href="javascript:chouma(1000);"><img src="{$skin}img/chips_1000000.png" class="img-responsive" alt="1000"></a>
                    </div>
                 
                </div>
                <div class="nav_ul">
                    <div class="nav_list">
                                                 <!--<p>第 <span class="red" id="no"></span> 期   </p>-->
                        <p><span>投注￥<span class="red" id="total">0</span></span>　余额￥<span class="red">{$info.points}</span></span></p>
                        <div class="nav_tz">
                            <dl>

                                <dd ><a href="javascript:remove();" class="btn btn-success btn-sqtz" style="margin-bottom: 2px;">清  除</a></dd>
							
                                <dt><a href="javascript:;" class="btn btn-danger btn-tz" onclick="tz()">确认投注</a></dt>
                            </dl>
                        </div>
                    </div>
                </div>
            </ul>
        </div>

    </div>
</nav>
<script type="text/javascript">
    var MAX_SCORE = {$pl.press_max};
    var MIN_SCORE = {$pl.press_min};
    var MY_SCORE = {};
    var GTYPE = {$pl.gameType};
    var PRESSNUM = '{$pl.pressNum}';
    var money=0,jf=0;
    var no='';
    var num=0;
    var curr_cm=0;
    var data = PRESSNUM.split(",");

   $(function () {
        $(".btn-qc").on('click',function () {
            $("#press ").removeClass('small-red');
        })
        $("#dx").on("click",'a',function () {
            useModel($(this).attr('rel'));
            $(this).addClass("small-red");
        })
        $("#press").on("click","a",function () {
            if($(this).hasClass("small-red")){
                $(this).removeClass("small-red");
            }else {
                $(this).addClass("small-red");
            }
            money=0;
            total();
        })
    });
    function remove(){
        for(var i= 0; i < data.length; i++) {
            $("#inNum" + i).val(0)
        }
        money=0;
        total();
    }
    function total() {
        $("#total").text(money);
    }
    function chouma(v) {

        usefenpei(v);
        total();
    }
    function tz() {
        var data = PRESSNUM.split(",");
        var total=0;
        money=0;
        var press="";
        for(var i= 0; i < data.length; i++) {
            var v=parseInt($("#inNum" + i).val());// * parseInt(data[i]);
            if(isNaN(v))v=0;
            money+=v;
            total+=v*1000;
            press+=parseInt(v*1000)+',';
        }
        console.info(money);
        if(money==0){
            alert("您还没有投注");return;
        }
        if(total > MAX_SCORE)
        {
            alert("您的投注额已大于最大限制" + MAX_SCORE);
            return;
        }
        if(total < MIN_SCORE)
        {
            alert("您的投注额小于最小限制" + MIN_SCORE);
            return;
        }
        if(!confirm("您确定投注 ¥" + money + " 吗?"))
            return;
        if(no==0){
            alert("请选择投资的期数");
            return;
        }
        $.ajax({
            type: "POST",
            url: "{:url('game/PostPress')}",
            data:{gtype:{$id},no:no,press:press},
            dataType: "json",
            timeout:3000,
            success: function(data){
                console.info(data);

                if(data.status==0){
                    alert("投注成功!");
                    location.href='{:url("game/game/id/$id")}';
                }else{
                    alert(data.message)
                }

            },
            error:function(){
            }
        });
        total();
    }
    function usefenpei(Input_Score){
        var totalScore = 0;
        var perScore = 0;
        var data = PRESSNUM.split(",");
        money=0;
        for(var i= 0; i < data.length; i++) {
            perScore=0;
            if($("#tbNum" + i).hasClass("active")){
                perScore = Input_Score +parseInt($("#inNum" + i).val());
                $("#inNum" + i).val(perScore)
                money += parseInt(perScore);
            }
        }
        return true;
    }
    $(function () {
        $("#press").on("mousedown",".item",function(event){
            if($(this).hasClass("active")){
                $(this).removeClass('active');
            }else {
                $(this).addClass('active');
                console.info($(this).find(".form-control").val())
                z=parseInt($(this).find(".form-control").val());
                console.info(z);
                if(isNaN(z)){
                    $(this).find(".form-control").val("0")
                    console.info("x")
                }
            }
        })
    });
</script>
</body>
</html>

